@import '@devui/theme/styles-var/devui-var.scss';

$font-size-map: (
  lg: $devui-font-size-lg,
  md: $devui-font-size-md,
  sm: $devui-font-size-sm,
);
$radio-width-map: (
  lg: 18px,
  md: 16px,
  sm: 14px,
);
$radio-label-height-map: (
  lg: $devui-size-lg,
  md: $devui-size-md,
  sm: $devui-size-sm,
);

.#{$devui-prefix}-radio {
  font-size: $devui-font-size;
  line-height: 1.5;
  font-weight: normal;
  cursor: pointer;
  color: $devui-text;

  &__wrapper {
    display: flex;
    justify-content: flex-start;
    align-items: center;
  }

  &:hover {
    .#{$devui-prefix}-radio__label {
      color: $devui-primary-hover;
    }
  }

  &:active,
  &:focus,
  &:hover {
    .#{$devui-prefix}-radio__material-outer {
      stroke: $devui-form-control-line-active;
    }

    .#{$devui-prefix}-radio__material-inner {
      fill: $devui-brand;
    }
  }

  &.active {
    .#{$devui-prefix}-radio__material-outer {
      opacity: 1;
      stroke: $devui-form-control-line-active;
      transition: stroke 50ms $devui-animation-ease-in-out;

      &.disabled {
        stroke: $devui-icon-fill-active-disabled;
        fill: transparent;
      }
    }

    .#{$devui-prefix}-radio__material-inner {
      opacity: 1;
      transform: scale(1);
      transition:
        transform $devui-animation-duration-base $devui-animation-ease-in-out,
        opacity $devui-animation-duration-base $devui-animation-ease-in-out;

      &.disabled {
        fill: $devui-icon-fill-active-disabled;
      }
    }

    &.#{$devui-prefix}-radio--bordered {
      border-color: $devui-primary-hover;
    }
  }

  &.disabled {
    cursor: not-allowed;

    /* 选择图标-外圈 */
    .#{$devui-prefix}-radio__material-outer {
      stroke: $devui-disabled-line;
      fill: $devui-disabled-bg;
    }

    /* 选择图标-内圈 */
    .#{$devui-prefix}-radio__material-inner {
      fill: $devui-icon-fill-active-disabled;
    }

    .#{$devui-prefix}-radio__label {
      color: $devui-disabled-text;
    }

    &.#{$devui-prefix}-radio--bordered {
      border-color: $devui-disabled-line;
    }
  }

  /* 选择图标-容器 */
  &__material {
    vertical-align: middle;
    position: relative;
    display: inline-block;
    overflow: hidden;
    height: 16px;
    width: 16px;
    line-height: 16px;
    user-select: none;
  }

  /* 选择图标-外圈 */
  &__material-outer {
    opacity: 1;
    transition: stroke 50ms cubic-bezier(0.755, 0.05, 0.855, 0.06);
    stroke: $devui-line;
    fill: transparent;
  }

  /* 选择图标-内圈 */
  &__material-inner {
    opacity: 0;
    transform: scale(0);
    transform-origin: 50% 50%;
    transition: transform 200ms cubic-bezier(0.755, 0.05, 0.855, 0.06), opacity 200ms cubic-bezier(0.755, 0.05, 0.855, 0.06);
    fill: $devui-brand;
  }

  /* 内容 */
  &__label {
    color: $devui-text;
    margin-left: 8px;
    font-size: $devui-font-size;
    transition: color $devui-animation-duration-slow $devui-animation-ease-in-out;
    line-height: 1;
  }

  &__input {
    opacity: 0;
    z-index: -1;
    width: 0;
    height: 0;
    display: none;
    overflow: hidden;
    pointer-events: none;
  }

  &--bordered {
    border: 1px solid $devui-disabled-line;
    border-radius: $devui-border-radius;
    padding: 0 15px 0 10px;
  }
  @each $size in ('lg', 'md', 'sm') {
    &.#{$devui-prefix}-radio--#{$size} {
      display: flex;
      align-items: center;

      .#{$devui-prefix}-radio__label {
        font-size: map-get($font-size-map, #{$size});
      }

      .#{$devui-prefix}-radio__material {
        width: map-get($radio-width-map, #{$size});
        height: map-get($radio-width-map, #{$size});

        & > svg {
          width: map-get($radio-width-map, #{$size});
          height: map-get($radio-width-map, #{$size});
        }
      }

      &.#{$devui-prefix}-radio--bordered {
        height: map-get($radio-label-height-map, #{$size});
      }
    }
  }
}
